package com.spzx.product.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName: categoryExcelListener
 * Package: com.spzx.product.listener
 * Description:
 *
 * @Author ycy
 * @Create 2024/8/5 16:20
 * @Version 1.0
 */
public class CategoryExcelListener<T> extends AnalysisEventListener<T> {
    //通过实例获取该值
    private List<T> datas = new ArrayList<>();
    @Override
    public void invoke(T t, AnalysisContext analysisContext) {
        datas.add(t);//数据存储到list 提供批量处理，或后续自己业务逻辑处理
    }

    public List<T> getDatas(){
        return datas;
    }
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        //解析完 Excel 后要执行的代码
    }
}
